import { fromJS, Map } from "immutable";
import { LOAD_TEST_DATA, SET_CURRENT_CITY } from "./actionCreator";
import {
  GET_TOPSECTION_DATA,
  GET_HOTSRECOMMEND_DATA,
  GET_VIPSCHEDULAR_DATA,
  GET_PERFORMANCETYPE_DATA,
  GET_TOURRECOMMEND_DATA,
  GET_TOPSHOPLIST_DATA,
  GET_SHOWLIST_DATA,
  GET_HEADSERCH_DATA,
  GET_HOTTHEATRE_DATA,
  GET_CHASEARCH_DATA,
  GET_LISTHEAD_DATA,
  GET_SHOWHEAD_DATA
} from "./actionType";
const defaultState = fromJS({
  num: 0,
  testList: [],
  currentCity: {
    city_id: "0",
    abbreviation: "",
    name: "全国"
  },
  topSection: {},
  hotsRecommendData: [],
  vipschedular: [],
  TourRecommend: [],
  toshoplist: [],
  tourRecommend: [],
  performancetype: [],
  showlist: [],
  hottheatre: [],
  headserch: {},
  chasearch: [],
  listDataSnv: [],
  showlistdata: []
});
export default (state = defaultState, action) => {
  // eslint-disable-next-line default-case
  switch (action.type) {
    case LOAD_TEST_DATA:
      return state.set("testList", fromJS(action.val));
    case SET_CURRENT_CITY:
      return state.update("currentCity", x => (x = Map(action.val)));
    case GET_HEADSERCH_DATA:
      return state.update("headserch", x => (x = Map(action.val)));
    case GET_TOPSECTION_DATA:
      return state.set("topSection", fromJS(action.val));
    case GET_HOTSRECOMMEND_DATA:
      return state.set("hotsRecommendData", fromJS(action.val));
    case GET_VIPSCHEDULAR_DATA:
      return state.set("vipschedular", fromJS(action.val));
    case GET_PERFORMANCETYPE_DATA:
      return state.set("performancetype", fromJS(action.val));
    case GET_TOPSHOPLIST_DATA:
      return state.set("toshoplist", fromJS(action.val));
    case GET_TOURRECOMMEND_DATA:
      return state.set("tourRecommend", fromJS(action.val));
    case GET_HOTTHEATRE_DATA:
      return state.set("hottheatre", fromJS(action.val));
    case GET_SHOWLIST_DATA:
      return state.set("showlist", fromJS(action.val));
    case GET_CHASEARCH_DATA:
      return state.set("chasearch", fromJS(action.val));
    case GET_LISTHEAD_DATA:
      return state.set("listDataSnv", fromJS(action.val));
    case GET_SHOWHEAD_DATA:
      return state.set("showlistdata", fromJS(action.val));
  }
  return state;
};
